<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MiXiM: csma Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MiXiM
   &#160;<span id="projectnumber">2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00067.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-types">Protected Types</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="#pro-attribs">Protected Attributes</a> &#124;
<a href="#pri-methods">Private Member Functions</a>  </div>
  <div class="headertitle">
<div class="title">csma Class Reference<div class="ingroups"><a class="el" href="a00525.html">CSMA - Classes for the CSMA implementation of MiXiM</a> &#124; <a class="el" href="a00509.html">macLayer - MAC layer modules</a></div></div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="csma" --><!-- doxytag: inherits="BaseMacLayer" -->
<p>Generic CSMA Mac-Layer.  
 <a href="a00067.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="a00426_source.html">csma.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for csma:</div>
<div class="dyncontent">
<div class="center"><img src="a00682.png" border="0" usemap="#csma_inherit__map" alt="Inheritance graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>
<div class="dynheader">
Collaboration diagram for csma:</div>
<div class="dyncontent">
<div class="center"><img src="a00683.png" border="0" usemap="#csma_coll__map" alt="Collaboration graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>

<p><a href="a00684.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#a24e7a48bd1d9036139c75b558ade4161">initialize</a> (int)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialization of the module and some variables.  <a href="#a24e7a48bd1d9036139c75b558ade4161"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a5820325a7d06db8ff3cc3caa25c2eec4"></a><!-- doxytag: member="csma::finish" ref="a5820325a7d06db8ff3cc3caa25c2eec4" args="()" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#a5820325a7d06db8ff3cc3caa25c2eec4">finish</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Delete all dynamically allocated objects of the module. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#afde05c6a829f672b556959acb26b0098">handleLowerMsg</a> (cMessage *)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Handle messages from lower layer.  <a href="#afde05c6a829f672b556959acb26b0098"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#ad85c18d90e41eb2074593a44b64ab855">handleUpperMsg</a> (cMessage *)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Handle messages from upper layer.  <a href="#ad85c18d90e41eb2074593a44b64ab855"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a95ef1a0e43d2f5d5fc9a4afb8754bc9e"></a><!-- doxytag: member="csma::handleSelfMsg" ref="a95ef1a0e43d2f5d5fc9a4afb8754bc9e" args="(cMessage *)" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#a95ef1a0e43d2f5d5fc9a4afb8754bc9e">handleSelfMsg</a> (cMessage *)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Handle self messages such as timers. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a168710b3b7dbb234bfa702d6ca10dfe3"></a><!-- doxytag: member="csma::handleLowerControl" ref="a168710b3b7dbb234bfa702d6ca10dfe3" args="(cMessage *msg)" -->
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#a168710b3b7dbb234bfa702d6ca10dfe3">handleLowerControl</a> (cMessage *msg)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Handle control messages from lower layer. <br/></td></tr>
<tr><td colspan="2"><h2><a name="pro-types"></a>
Protected Types</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#a1f50989b69d70d63619ace8d8f9a0165">t_mac_states</a> { <br/>
&#160;&#160;<b>IDLE_1</b> = 1, 
<b>BACKOFF_2</b>, 
<b>CCA_3</b>, 
<b>TRANSMITFRAME_4</b>, 
<br/>
&#160;&#160;<b>WAITACK_5</b>, 
<b>WAITSIFS_6</b>, 
<b>TRANSMITACK_7</b>
<br/>
 }</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">MAC states see states diagram. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#ab33d8c1261a8e13f526a63364232a19e">t_mac_timer</a> { <br/>
&#160;&#160;<b>TIMER_NULL</b> = 0, 
<b>TIMER_BACKOFF</b>, 
<b>TIMER_CCA</b>, 
<b>TIMER_SIFS</b>, 
<br/>
&#160;&#160;<b>TIMER_RX_ACK</b>
<br/>
 }</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Kinds for timer messages. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#abd06e4672cf1a3553d72011f458f78a2">t_mac_event</a> { <br/>
&#160;&#160;<b>EV_SEND_REQUEST</b> = 1, 
<b>EV_TIMER_BACKOFF</b>, 
<b>EV_FRAME_TRANSMITTED</b>, 
<b>EV_ACK_RECEIVED</b>, 
<br/>
&#160;&#160;<b>EV_ACK_TIMEOUT</b>, 
<b>EV_FRAME_RECEIVED</b>, 
<b>EV_DUPLICATE_RECEIVED</b>, 
<b>EV_TIMER_SIFS</b>, 
<br/>
&#160;&#160;<b>EV_BROADCAST_RECEIVED</b>, 
<b>EV_TIMER_CCA</b>
<br/>
 }</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">MAC state machine events. See state diagram. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#ae008d14977310cab31c835efffcb02e7">t_csma_frame_types</a> { <b>DATA</b>, 
<b>ACK</b>
 }</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Types for frames sent by the CSMA. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><b>t_mac_carrier_sensed</b> { <b>CHANNEL_BUSY</b> = 1, 
<b>CHANNEL_FREE</b>
 }</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><b>t_mac_status</b> { <br/>
&#160;&#160;<b>STATUS_OK</b> = 1, 
<b>STATUS_ERROR</b>, 
<b>STATUS_RX_ERROR</b>, 
<b>STATUS_RX_TIMEOUT</b>, 
<br/>
&#160;&#160;<b>STATUS_FRAME_TO_PROCESS</b>, 
<b>STATUS_NO_FRAME_TO_PROCESS</b>, 
<b>STATUS_FRAME_TRANSMITTED</b>
<br/>
 }</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#ad6c37215e83748e9270a9772727f021d">backoff_methods</a> { <a class="el" href="a00067.html#ad6c37215e83748e9270a9772727f021da7ff1f1cf6a8bc1239290f360074513c5">CONSTANT</a> =  0, 
<a class="el" href="a00067.html#ad6c37215e83748e9270a9772727f021da990e04ecf52a42619a49d0161f4f3421">LINEAR</a>, 
<a class="el" href="a00067.html#ad6c37215e83748e9270a9772727f021dab16652c86ace580cf5279d6c1538f549">EXPONENTIAL</a>
 }</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">The different back-off methods.  <a href="a00067.html#ad6c37215e83748e9270a9772727f021d">More...</a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a79da8cd3daf19141aac1706cedbc1962"></a><!-- doxytag: member="csma::MacQueue" ref="a79da8cd3daf19141aac1706cedbc1962" args="" -->
typedef std::list&lt; macpkt_ptr_t &gt;&#160;</td><td class="memItemRight" valign="bottom"><b>MacQueue</b></td></tr>
<tr><td colspan="2"><h2><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a71d4cce10b4ad207dff72a2dc899c763"></a><!-- doxytag: member="csma::fsmError" ref="a71d4cce10b4ad207dff72a2dc899c763" args="(t_mac_event event, cMessage *msg)" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>fsmError</b> (<a class="el" href="a00067.html#abd06e4672cf1a3553d72011f458f78a2">t_mac_event</a> event, cMessage *msg)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#a23b4dba9c913ac458f38091b2a7de71d">executeMac</a> (<a class="el" href="a00067.html#abd06e4672cf1a3553d72011f458f78a2">t_mac_event</a> event, cMessage *msg)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a74e6f7f3cfe6fc22a20395068dc5854b"></a><!-- doxytag: member="csma::updateStatusIdle" ref="a74e6f7f3cfe6fc22a20395068dc5854b" args="(t_mac_event event, cMessage *msg)" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>updateStatusIdle</b> (<a class="el" href="a00067.html#abd06e4672cf1a3553d72011f458f78a2">t_mac_event</a> event, cMessage *msg)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a846e73980dbac87e941d4067bfe7e320"></a><!-- doxytag: member="csma::updateStatusBackoff" ref="a846e73980dbac87e941d4067bfe7e320" args="(t_mac_event event, cMessage *msg)" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>updateStatusBackoff</b> (<a class="el" href="a00067.html#abd06e4672cf1a3553d72011f458f78a2">t_mac_event</a> event, cMessage *msg)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a659ab8373554bc363561653873612046"></a><!-- doxytag: member="csma::updateStatusCCA" ref="a659ab8373554bc363561653873612046" args="(t_mac_event event, cMessage *msg)" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>updateStatusCCA</b> (<a class="el" href="a00067.html#abd06e4672cf1a3553d72011f458f78a2">t_mac_event</a> event, cMessage *msg)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ab30d80ba0fac748a7506b9d3f53d2f43"></a><!-- doxytag: member="csma::updateStatusTransmitFrame" ref="ab30d80ba0fac748a7506b9d3f53d2f43" args="(t_mac_event event, cMessage *msg)" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>updateStatusTransmitFrame</b> (<a class="el" href="a00067.html#abd06e4672cf1a3553d72011f458f78a2">t_mac_event</a> event, cMessage *msg)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a700f2c0a1a9674a839eeb7dd8293f8b3"></a><!-- doxytag: member="csma::updateStatusWaitAck" ref="a700f2c0a1a9674a839eeb7dd8293f8b3" args="(t_mac_event event, cMessage *msg)" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>updateStatusWaitAck</b> (<a class="el" href="a00067.html#abd06e4672cf1a3553d72011f458f78a2">t_mac_event</a> event, cMessage *msg)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a2a6f92b0cd5938f1be719482512f2dd1"></a><!-- doxytag: member="csma::updateStatusSIFS" ref="a2a6f92b0cd5938f1be719482512f2dd1" args="(t_mac_event event, cMessage *msg)" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>updateStatusSIFS</b> (<a class="el" href="a00067.html#abd06e4672cf1a3553d72011f458f78a2">t_mac_event</a> event, cMessage *msg)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a9129584efe51093888018a0571e94593"></a><!-- doxytag: member="csma::updateStatusTransmitAck" ref="a9129584efe51093888018a0571e94593" args="(t_mac_event event, cMessage *msg)" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>updateStatusTransmitAck</b> (<a class="el" href="a00067.html#abd06e4672cf1a3553d72011f458f78a2">t_mac_event</a> event, cMessage *msg)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae4bda74e9b02b7ad58f495014e295bf6"></a><!-- doxytag: member="csma::updateStatusNotIdle" ref="ae4bda74e9b02b7ad58f495014e295bf6" args="(cMessage *msg)" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>updateStatusNotIdle</b> (cMessage *msg)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ab91e92b51bec42503481463ed363c2ae"></a><!-- doxytag: member="csma::manageQueue" ref="ab91e92b51bec42503481463ed363c2ae" args="()" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>manageQueue</b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aaf107192d5d0acf1ff97c5824e6f8084"></a><!-- doxytag: member="csma::updateMacState" ref="aaf107192d5d0acf1ff97c5824e6f8084" args="(t_mac_states newMacState)" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>updateMacState</b> (<a class="el" href="a00067.html#a1f50989b69d70d63619ace8d8f9a0165">t_mac_states</a> newMacState)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="adbb1cf93b9df290bac431dba44182c1d"></a><!-- doxytag: member="csma::attachSignal" ref="adbb1cf93b9df290bac431dba44182c1d" args="(macpkt_ptr_t mac, simtime_t_cref startTime)" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>attachSignal</b> (macpkt_ptr_t mac, simtime_t_cref startTime)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ad300d103185ad00ddae38b8cc471ead6"></a><!-- doxytag: member="csma::manageMissingAck" ref="ad300d103185ad00ddae38b8cc471ead6" args="(t_mac_event event, cMessage *msg)" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>manageMissingAck</b> (<a class="el" href="a00067.html#abd06e4672cf1a3553d72011f458f78a2">t_mac_event</a> event, cMessage *msg)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae31eb7f8a6f2a44081f63fe51857cd19"></a><!-- doxytag: member="csma::startTimer" ref="ae31eb7f8a6f2a44081f63fe51857cd19" args="(t_mac_timer timer)" -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>startTimer</b> (<a class="el" href="a00067.html#ab33d8c1261a8e13f526a63364232a19e">t_mac_timer</a> timer)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a3267a23dff0a5bcc0291a0f5554b7e48"></a><!-- doxytag: member="csma::scheduleBackoff" ref="a3267a23dff0a5bcc0291a0f5554b7e48" args="()" -->
virtual simtime_t&#160;</td><td class="memItemRight" valign="bottom"><b>scheduleBackoff</b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual cPacket *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#aedcaefc83f850c1ca35836cb223b412e">decapsMsg</a> (macpkt_ptr_t macPkt)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">decapsulate the network message from the MacPkt  <a href="#aedcaefc83f850c1ca35836cb223b412e"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="pro-attribs"></a>
Protected Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a1b4834898677ae70f70e336a5af6bea4"></a><!-- doxytag: member="csma::stats" ref="a1b4834898677ae70f70e336a5af6bea4" args="" -->
bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#a1b4834898677ae70f70e336a5af6bea4">stats</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Records general statistics? <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="af0459af5600cded297d8baaebf93270a"></a><!-- doxytag: member="csma::trace" ref="af0459af5600cded297d8baaebf93270a" args="" -->
bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#af0459af5600cded297d8baaebf93270a">trace</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Record out put vectors? <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a412a3b42a3212ab8a5dd1fcca2976d75"></a><!-- doxytag: member="csma::macState" ref="a412a3b42a3212ab8a5dd1fcca2976d75" args="" -->
<a class="el" href="a00067.html#a1f50989b69d70d63619ace8d8f9a0165">t_mac_states</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#a412a3b42a3212ab8a5dd1fcca2976d75">macState</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">keep track of MAC state <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a77ff57b2f2a464a2c6646a74dd7435bd"></a><!-- doxytag: member="csma::status" ref="a77ff57b2f2a464a2c6646a74dd7435bd" args="" -->
t_mac_status&#160;</td><td class="memItemRight" valign="bottom"><b>status</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">simtime_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#a4c4485a6c261026fbb39eee038c61d35">sifs</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Maximum time between a packet and its ACK.  <a href="#a4c4485a6c261026fbb39eee038c61d35"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ac9f2b5914cfbdd9763531913f0756eb7"></a><!-- doxytag: member="csma::macAckWaitDuration" ref="ac9f2b5914cfbdd9763531913f0756eb7" args="" -->
simtime_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#ac9f2b5914cfbdd9763531913f0756eb7">macAckWaitDuration</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">The amount of time the MAC waits for the ACK of a packet. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ac818d4052c62aa85c11c5a89aba20866"></a><!-- doxytag: member="csma::transmissionAttemptInterruptedByRx" ref="ac818d4052c62aa85c11c5a89aba20866" args="" -->
bool&#160;</td><td class="memItemRight" valign="bottom"><b>transmissionAttemptInterruptedByRx</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae54073ef32d73822112cbc3ccfd5cd20"></a><!-- doxytag: member="csma::ccaDetectionTime" ref="ae54073ef32d73822112cbc3ccfd5cd20" args="" -->
simtime_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#ae54073ef32d73822112cbc3ccfd5cd20">ccaDetectionTime</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">CCA detection time. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a2de1e148306253a3b7a33ae2c47201dc"></a><!-- doxytag: member="csma::rxSetupTime" ref="a2de1e148306253a3b7a33ae2c47201dc" args="" -->
simtime_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#a2de1e148306253a3b7a33ae2c47201dc">rxSetupTime</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Time to setup radio from sleep to Rx state. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ac820e37e2f86d7131a66aa6d1636cd69"></a><!-- doxytag: member="csma::aTurnaroundTime" ref="ac820e37e2f86d7131a66aa6d1636cd69" args="" -->
simtime_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#ac820e37e2f86d7131a66aa6d1636cd69">aTurnaroundTime</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Time to switch radio from Rx to Tx state. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a8651bf006f28d69523c43d2aea774f7c"></a><!-- doxytag: member="csma::macMaxCSMABackoffs" ref="a8651bf006f28d69523c43d2aea774f7c" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#a8651bf006f28d69523c43d2aea774f7c">macMaxCSMABackoffs</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">maximum number of backoffs before frame drop <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="af7b3c7c2d0028579026dd17a267d4a72"></a><!-- doxytag: member="csma::macMaxFrameRetries" ref="af7b3c7c2d0028579026dd17a267d4a72" args="" -->
unsigned int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#af7b3c7c2d0028579026dd17a267d4a72">macMaxFrameRetries</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">maximum number of frame retransmissions without ack <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a63f8c5595546dedb2d2f779b2f88fc7b"></a><!-- doxytag: member="csma::aUnitBackoffPeriod" ref="a63f8c5595546dedb2d2f779b2f88fc7b" args="" -->
simtime_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#a63f8c5595546dedb2d2f779b2f88fc7b">aUnitBackoffPeriod</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">base time unit for calculating backoff durations <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a51f34d63f063978e4077e290ed96579d"></a><!-- doxytag: member="csma::useMACAcks" ref="a51f34d63f063978e4077e290ed96579d" args="" -->
bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#a51f34d63f063978e4077e290ed96579d">useMACAcks</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Stores if the MAC expects Acks for Unicast packets. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="af9dc9268929f470a2b1dc196f4dd1ad0"></a><!-- doxytag: member="csma::backoffMethod" ref="af9dc9268929f470a2b1dc196f4dd1ad0" args="" -->
<a class="el" href="a00067.html#ad6c37215e83748e9270a9772727f021d">backoff_methods</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#af9dc9268929f470a2b1dc196f4dd1ad0">backoffMethod</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Defines the backoff method to be used. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aec2a85f71170231d175a7e5f453488bf"></a><!-- doxytag: member="csma::macMinBE" ref="aec2a85f71170231d175a7e5f453488bf" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#aec2a85f71170231d175a7e5f453488bf">macMinBE</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Minimum backoff exponent. Only used for exponential backoff method. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a07d8675d0999963f22caa47b90feee7b"></a><!-- doxytag: member="csma::macMaxBE" ref="a07d8675d0999963f22caa47b90feee7b" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#a07d8675d0999963f22caa47b90feee7b">macMaxBE</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Maximum backoff exponent. Only used for exponential backoff method. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aa2d96f20753eff74aa1b9b3251523d24"></a><!-- doxytag: member="csma::initialCW" ref="aa2d96f20753eff74aa1b9b3251523d24" args="" -->
double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#aa2d96f20753eff74aa1b9b3251523d24">initialCW</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">initial contention window size Only used for linear and constant backoff method. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a45229ade2d3472af4c427384443fbd9f"></a><!-- doxytag: member="csma::txPower" ref="a45229ade2d3472af4c427384443fbd9f" args="" -->
double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#a45229ade2d3472af4c427384443fbd9f">txPower</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">The power (in mW) to transmit with. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aa01f7215a8fccd726da22a0721994580"></a><!-- doxytag: member="csma::NB" ref="aa01f7215a8fccd726da22a0721994580" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#aa01f7215a8fccd726da22a0721994580">NB</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">number of backoff performed until now for current frame <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ac75e73d1a95881bcdcb125f13876e996"></a><!-- doxytag: member="csma::macQueue" ref="ac75e73d1a95881bcdcb125f13876e996" args="" -->
MacQueue&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#ac75e73d1a95881bcdcb125f13876e996">macQueue</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">A queue to store packets from upper layer in case another packet is still waiting for transmission.. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a6c5dda6e483befcd9166dd2d1c099ff1"></a><!-- doxytag: member="csma::queueLength" ref="a6c5dda6e483befcd9166dd2d1c099ff1" args="" -->
unsigned int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#a6c5dda6e483befcd9166dd2d1c099ff1">queueLength</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">length of the queue <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">unsigned int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#a6249492db8b5f2240aefd33ba1bbf04e">txAttempts</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">count the number of tx attempts  <a href="#a6249492db8b5f2240aefd33ba1bbf04e"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="af881ff622dc82a06fc14008d67a0d084"></a><!-- doxytag: member="csma::bitrate" ref="af881ff622dc82a06fc14008d67a0d084" args="" -->
double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#af881ff622dc82a06fc14008d67a0d084">bitrate</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">the bit rate at which we transmit <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ab8c7954aa7b5dc31268b3673a358e9f9"></a><!-- doxytag: member="csma::droppedPacket" ref="ab8c7954aa7b5dc31268b3673a358e9f9" args="" -->
<a class="el" href="a00088.html">DroppedPacket</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#ab8c7954aa7b5dc31268b3673a358e9f9">droppedPacket</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Inspect reasons for dropped packets. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a384d9dce68d3db1b258369095e5b12a4"></a><!-- doxytag: member="csma::nicId" ref="a384d9dce68d3db1b258369095e5b12a4" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#a384d9dce68d3db1b258369095e5b12a4">nicId</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">publish dropped packets nic wide <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a3fba7040140a46c800ea94560fe0113a"></a><!-- doxytag: member="csma::ackLength" ref="a3fba7040140a46c800ea94560fe0113a" args="" -->
int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#a3fba7040140a46c800ea94560fe0113a">ackLength</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">The bit length of the ACK packet. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ab36cfe2a1e2cc3a9e9d438c717c2c81c"></a><!-- doxytag: member="csma::ackMessage" ref="ab36cfe2a1e2cc3a9e9d438c717c2c81c" args="" -->
macpkt_ptr_t&#160;</td><td class="memItemRight" valign="bottom"><b>ackMessage</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="af74178ef86747295323916261137aa50"></a><!-- doxytag: member="csma::SeqNrParent" ref="af74178ef86747295323916261137aa50" args="" -->
std::map&lt; <a class="el" href="a00117.html#aea56b60dcb5ae8c2bde465271daf7210">LAddress::L2Type</a>, <br class="typebreak"/>
unsigned long &gt;&#160;</td><td class="memItemRight" valign="bottom"><b>SeqNrParent</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a05b34fcf68ecdf0a79c0bb62c51fcbfb"></a><!-- doxytag: member="csma::SeqNrChild" ref="a05b34fcf68ecdf0a79c0bb62c51fcbfb" args="" -->
std::map&lt; <a class="el" href="a00117.html#aea56b60dcb5ae8c2bde465271daf7210">LAddress::L2Type</a>, <br class="typebreak"/>
unsigned long &gt;&#160;</td><td class="memItemRight" valign="bottom"><b>SeqNrChild</b></td></tr>
<tr><td colspan="2"><div class="groupHeader">Different tracked statistics.</div></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="af02666990b6829d641052aa586985647"></a><!-- doxytag: member="csma::nbTxFrames" ref="af02666990b6829d641052aa586985647" args="" -->
long&#160;</td><td class="memItemRight" valign="bottom"><b>nbTxFrames</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aa3aefb9f933191568678e1eceea44b94"></a><!-- doxytag: member="csma::nbRxFrames" ref="aa3aefb9f933191568678e1eceea44b94" args="" -->
long&#160;</td><td class="memItemRight" valign="bottom"><b>nbRxFrames</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a2327ecf7f33f21a0636ecb9e503fe51c"></a><!-- doxytag: member="csma::nbMissedAcks" ref="a2327ecf7f33f21a0636ecb9e503fe51c" args="" -->
long&#160;</td><td class="memItemRight" valign="bottom"><b>nbMissedAcks</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a8f39332bf755daf4831639d0691103eb"></a><!-- doxytag: member="csma::nbRecvdAcks" ref="a8f39332bf755daf4831639d0691103eb" args="" -->
long&#160;</td><td class="memItemRight" valign="bottom"><b>nbRecvdAcks</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="af153b698e40a2ff960726d2484ce3064"></a><!-- doxytag: member="csma::nbDroppedFrames" ref="af153b698e40a2ff960726d2484ce3064" args="" -->
long&#160;</td><td class="memItemRight" valign="bottom"><b>nbDroppedFrames</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a770580278f2fc81aa2b93a57f956f1d0"></a><!-- doxytag: member="csma::nbTxAcks" ref="a770580278f2fc81aa2b93a57f956f1d0" args="" -->
long&#160;</td><td class="memItemRight" valign="bottom"><b>nbTxAcks</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aa34632eec8c573fa05868eaed0026028"></a><!-- doxytag: member="csma::nbDuplicates" ref="aa34632eec8c573fa05868eaed0026028" args="" -->
long&#160;</td><td class="memItemRight" valign="bottom"><b>nbDuplicates</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a287036b883dda56bf7cc2c1de600525a"></a><!-- doxytag: member="csma::nbBackoffs" ref="a287036b883dda56bf7cc2c1de600525a" args="" -->
long&#160;</td><td class="memItemRight" valign="bottom"><b>nbBackoffs</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a43a9a6dcb52ab4303d6362a5ed6a0084"></a><!-- doxytag: member="csma::backoffValues" ref="a43a9a6dcb52ab4303d6362a5ed6a0084" args="" -->
double&#160;</td><td class="memItemRight" valign="bottom"><b>backoffValues</b></td></tr>
<tr><td colspan="2"><div class="groupHeader">Pointer for timer messages.</div></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a2b7fda303bef70518f6991bdc2dbbc26"></a><!-- doxytag: member="csma::backoffTimer" ref="a2b7fda303bef70518f6991bdc2dbbc26" args="" -->
cMessage *&#160;</td><td class="memItemRight" valign="bottom"><b>backoffTimer</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a51882c996d78112cd1af01ff89e50f81"></a><!-- doxytag: member="csma::ccaTimer" ref="a51882c996d78112cd1af01ff89e50f81" args="" -->
cMessage *&#160;</td><td class="memItemRight" valign="bottom"><b>ccaTimer</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a47cf3021810d0ae2842eb2f0889cd5b8"></a><!-- doxytag: member="csma::sifsTimer" ref="a47cf3021810d0ae2842eb2f0889cd5b8" args="" -->
cMessage *&#160;</td><td class="memItemRight" valign="bottom"><b>sifsTimer</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a98eb459c7e4871dc14864bce8c9ea0e1"></a><!-- doxytag: member="csma::rxAckTimer" ref="a98eb459c7e4871dc14864bce8c9ea0e1" args="" -->
cMessage *&#160;</td><td class="memItemRight" valign="bottom"><b>rxAckTimer</b></td></tr>
<tr><td colspan="2"><h2><a name="pri-methods"></a>
Private Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a038a379e63dda186c937524aca6d02d3"></a><!-- doxytag: member="csma::csma" ref="a038a379e63dda186c937524aca6d02d3" args="(const csma &amp;)" -->
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#a038a379e63dda186c937524aca6d02d3">csma</a> (const <a class="el" href="a00067.html">csma</a> &amp;)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Copy constructor is not allowed. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a582f528dcdac17083332fd6ee1799195"></a><!-- doxytag: member="csma::operator=" ref="a582f528dcdac17083332fd6ee1799195" args="(const csma &amp;)" -->
<a class="el" href="a00067.html">csma</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html#a582f528dcdac17083332fd6ee1799195">operator=</a> (const <a class="el" href="a00067.html">csma</a> &amp;)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Assignment operator is not allowed. <br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>Generic CSMA Mac-Layer. </p>
<p>Supports constant, linear and exponential backoffs as well as MAC ACKs.</p>
<dl class="author"><dt><b>Author:</b></dt><dd>Jerome Rousselot, Amre El-Hoiydi, Marc Loebbers, Yosia Hadisusanto, Andreas Koepke </dd>
<dd>
Karl Wessel (port for MiXiM)</dd></dl>
<div class="image">
<img src="csmaFSM.png" alt="csmaFSM.png"/>
<div class="caption">
CSMA Mac-Layer - finite state machine</div></div>
</div><hr/><h2>Member Enumeration Documentation</h2>
<a class="anchor" id="ad6c37215e83748e9270a9772727f021d"></a><!-- doxytag: member="csma::backoff_methods" ref="ad6c37215e83748e9270a9772727f021d" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="a00067.html#ad6c37215e83748e9270a9772727f021d">csma::backoff_methods</a><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>The different back-off methods. </p>
<dl><dt><b>Enumerator: </b></dt><dd><table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><em><a class="anchor" id="ad6c37215e83748e9270a9772727f021da7ff1f1cf6a8bc1239290f360074513c5"></a><!-- doxytag: member="CONSTANT" ref="ad6c37215e83748e9270a9772727f021da7ff1f1cf6a8bc1239290f360074513c5" args="" -->CONSTANT</em>&nbsp;</td><td>
<p>Constant back-off time. </p>
</td></tr>
<tr><td valign="top"><em><a class="anchor" id="ad6c37215e83748e9270a9772727f021da990e04ecf52a42619a49d0161f4f3421"></a><!-- doxytag: member="LINEAR" ref="ad6c37215e83748e9270a9772727f021da990e04ecf52a42619a49d0161f4f3421" args="" -->LINEAR</em>&nbsp;</td><td>
<p><a class="el" href="a00118.html" title="Given two iterators defining a range of key-value-pairs this class provides linear interpolation of t...">Linear</a> increasing back-off time. </p>
</td></tr>
<tr><td valign="top"><em><a class="anchor" id="ad6c37215e83748e9270a9772727f021dab16652c86ace580cf5279d6c1538f549"></a><!-- doxytag: member="EXPONENTIAL" ref="ad6c37215e83748e9270a9772727f021dab16652c86ace580cf5279d6c1538f549" args="" -->EXPONENTIAL</em>&nbsp;</td><td>
<p>Exponentially increasing back-off time. </p>
</td></tr>
</table>
</dd>
</dl>
<div class="fragment"><pre class="fragment">                         {
      <a class="code" href="a00067.html#ad6c37215e83748e9270a9772727f021da7ff1f1cf6a8bc1239290f360074513c5" title="Constant back-off time.">CONSTANT</a> = 0,
      <a class="code" href="a00067.html#ad6c37215e83748e9270a9772727f021da990e04ecf52a42619a49d0161f4f3421" title="Linear increasing back-off time.">LINEAR</a>,
      <a class="code" href="a00067.html#ad6c37215e83748e9270a9772727f021dab16652c86ace580cf5279d6c1538f549" title="Exponentially increasing back-off time.">EXPONENTIAL</a>,
    };
</pre></div>
</div>
</div>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="aedcaefc83f850c1ca35836cb223b412e"></a><!-- doxytag: member="csma::decapsMsg" ref="aedcaefc83f850c1ca35836cb223b412e" args="(macpkt_ptr_t macPkt)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cPacket * csma::decapsMsg </td>
          <td>(</td>
          <td class="paramtype">macpkt_ptr_t&#160;</td>
          <td class="paramname"><em>msg</em></td><td>)</td>
          <td><code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>decapsulate the network message from the MacPkt </p>
<p>Decapsulates the network packet from the received MacPkt </p>

<p>Reimplemented from <a class="el" href="a00026.html#a998b4c4c56074a354b50f8c4fc5d6d4c">BaseMacLayer</a>.</p>

<p>Reimplemented in <a class="el" href="a00068.html#ab2174202ba00f0731fc9924597aba925">CSMA802154</a>.</p>

<p>References <a class="el" href="a00026.html#a3f1d2f1614a5d25f8b5f64b74e1c40a7">BaseMacLayer::setUpControlInfo()</a>.</p>
<div class="fragment"><pre class="fragment">                                            {
  cPacket * msg = macPkt-&gt;decapsulate();
  <a class="code" href="a00026.html#a3f1d2f1614a5d25f8b5f64b74e1c40a7" title="Attaches a &quot;control info&quot; (MacToNetw) structure (object) to the message pMsg.">setUpControlInfo</a>(msg, macPkt-&gt;getSrcAddr());

  <span class="keywordflow">return</span> msg;
}
</pre></div>
</div>
</div>
<a class="anchor" id="a23b4dba9c913ac458f38091b2a7de71d"></a><!-- doxytag: member="csma::executeMac" ref="a23b4dba9c913ac458f38091b2a7de71d" args="(t_mac_event event, cMessage *msg)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void csma::executeMac </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="a00067.html#abd06e4672cf1a3553d72011f458f78a2">t_mac_event</a>&#160;</td>
          <td class="paramname"><em>event</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">cMessage *&#160;</td>
          <td class="paramname"><em>msg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Updates state machine. </p>

<p>References <a class="el" href="a00067.html#a412a3b42a3212ab8a5dd1fcca2976d75">macState</a>.</p>

<p>Referenced by <a class="el" href="a00067.html#a168710b3b7dbb234bfa702d6ca10dfe3">handleLowerControl()</a>, <a class="el" href="a00067.html#afde05c6a829f672b556959acb26b0098">handleLowerMsg()</a>, <a class="el" href="a00067.html#a95ef1a0e43d2f5d5fc9a4afb8754bc9e">handleSelfMsg()</a>, and <a class="el" href="a00067.html#ad85c18d90e41eb2074593a44b64ab855">handleUpperMsg()</a>.</p>
<div class="fragment"><pre class="fragment">                                                      {
  debugEV&lt;&lt; <span class="stringliteral">&quot;In executeMac&quot;</span> &lt;&lt; endl;
  <span class="keywordflow">if</span>(<a class="code" href="a00067.html#a412a3b42a3212ab8a5dd1fcca2976d75" title="keep track of MAC state">macState</a> != IDLE_1 &amp;&amp; event == EV_SEND_REQUEST) {
    updateStatusNotIdle(msg);
  } <span class="keywordflow">else</span> {
    <span class="keywordflow">switch</span>(<a class="code" href="a00067.html#a412a3b42a3212ab8a5dd1fcca2976d75" title="keep track of MAC state">macState</a>) {
    <span class="keywordflow">case</span> IDLE_1:
      updateStatusIdle(event, msg);
      <span class="keywordflow">break</span>;
    <span class="keywordflow">case</span> BACKOFF_2:
      updateStatusBackoff(event, msg);
      <span class="keywordflow">break</span>;
    <span class="keywordflow">case</span> CCA_3:
      updateStatusCCA(event, msg);
      <span class="keywordflow">break</span>;
    <span class="keywordflow">case</span> TRANSMITFRAME_4:
      updateStatusTransmitFrame(event, msg);
      <span class="keywordflow">break</span>;
    <span class="keywordflow">case</span> WAITACK_5:
      updateStatusWaitAck(event, msg);
      <span class="keywordflow">break</span>;
    <span class="keywordflow">case</span> WAITSIFS_6:
      updateStatusSIFS(event, msg);
      <span class="keywordflow">break</span>;
    <span class="keywordflow">case</span> TRANSMITACK_7:
      updateStatusTransmitAck(event, msg);
      <span class="keywordflow">break</span>;
    <span class="keywordflow">default</span>:
      EV &lt;&lt; <span class="stringliteral">&quot;Error in CSMA FSM: an unknown state has been reached. macState=&quot;</span> &lt;&lt; <a class="code" href="a00067.html#a412a3b42a3212ab8a5dd1fcca2976d75" title="keep track of MAC state">macState</a> &lt;&lt; endl;
      <span class="keywordflow">break</span>;
    }
  }
}
</pre></div>
</div>
</div>
<a class="anchor" id="afde05c6a829f672b556959acb26b0098"></a><!-- doxytag: member="csma::handleLowerMsg" ref="afde05c6a829f672b556959acb26b0098" args="(cMessage *)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void csma::handleLowerMsg </td>
          <td>(</td>
          <td class="paramtype">cMessage *&#160;</td>
          <td class="paramname"><em>msg</em></td><td>)</td>
          <td><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Handle messages from lower layer. </p>
<p>Compares the address of this Host with the destination address in frame. Generates the corresponding event. </p>

<p>Reimplemented from <a class="el" href="a00026.html#a413375cec02b990a521b62086a02264c">BaseMacLayer</a>.</p>

<p>References <a class="el" href="a00067.html#a3fba7040140a46c800ea94560fe0113a">ackLength</a>, <a class="el" href="a00067.html#a23b4dba9c913ac458f38091b2a7de71d">executeMac()</a>, <a class="el" href="a00117.html#a3890f1c7314c5695e32252468e6bd5a5">LAddress::isL2Broadcast()</a>, <a class="el" href="a00067.html#ac75e73d1a95881bcdcb125f13876e996">macQueue</a>, <a class="el" href="a00067.html#a412a3b42a3212ab8a5dd1fcca2976d75">macState</a>, <a class="el" href="a00026.html#a8a26df9da07801d8ccb530530ef57ee2">BaseMacLayer::myMacAddr</a>, and <a class="el" href="a00067.html#a51f34d63f063978e4077e290ed96579d">useMACAcks</a>.</p>
<div class="fragment"><pre class="fragment">                                       {
    macpkt_ptr_t            macPkt     = <span class="keyword">static_cast&lt;</span>macpkt_ptr_t<span class="keyword">&gt;</span> (msg);
  <span class="keyword">const</span> <a class="code" href="a00117.html#aea56b60dcb5ae8c2bde465271daf7210" title="Type definition for a L2 (MAC) address.">LAddress::L2Type</a>&amp; src        = macPkt-&gt;getSrcAddr();
  <span class="keyword">const</span> <a class="code" href="a00117.html#aea56b60dcb5ae8c2bde465271daf7210" title="Type definition for a L2 (MAC) address.">LAddress::L2Type</a>&amp; dest       = macPkt-&gt;getDestAddr();
  <span class="keywordtype">long</span>                    ExpectedNr = 0;

  debugEV&lt;&lt; <span class="stringliteral">&quot;Received frame name= &quot;</span> &lt;&lt; macPkt-&gt;getName()
  &lt;&lt; <span class="stringliteral">&quot;, myState=&quot;</span> &lt;&lt; <a class="code" href="a00067.html#a412a3b42a3212ab8a5dd1fcca2976d75" title="keep track of MAC state">macState</a> &lt;&lt; <span class="stringliteral">&quot; src=&quot;</span> &lt;&lt; src
  &lt;&lt; <span class="stringliteral">&quot; dst=&quot;</span> &lt;&lt; dest &lt;&lt; <span class="stringliteral">&quot; myAddr=&quot;</span>
  &lt;&lt; <a class="code" href="a00026.html#a8a26df9da07801d8ccb530530ef57ee2" title="MAC address.">myMacAddr</a> &lt;&lt; endl;

  <span class="keywordflow">if</span>(dest == <a class="code" href="a00026.html#a8a26df9da07801d8ccb530530ef57ee2" title="MAC address.">myMacAddr</a>)
  {
    <span class="keywordflow">if</span>(!<a class="code" href="a00067.html#a51f34d63f063978e4077e290ed96579d" title="Stores if the MAC expects Acks for Unicast packets.">useMACAcks</a>) {
      debugEV &lt;&lt; <span class="stringliteral">&quot;Received a data packet addressed to me.&quot;</span> &lt;&lt; endl;
<span class="comment">//      nbRxFrames++;</span>
      <a class="code" href="a00067.html#a23b4dba9c913ac458f38091b2a7de71d">executeMac</a>(EV_FRAME_RECEIVED, macPkt);
    }
    <span class="keywordflow">else</span> {
      <span class="keywordtype">long</span> SeqNr = macPkt-&gt;getSequenceId();

      <span class="keywordflow">if</span>(strcmp(macPkt-&gt;getName(), <span class="stringliteral">&quot;CSMA-Ack&quot;</span>) != 0) {
        <span class="comment">// This is a data message addressed to us</span>
        <span class="comment">// and we should send an ack.</span>
        <span class="comment">// we build the ack packet here because we need to</span>
        <span class="comment">// copy data from macPkt (src).</span>
        debugEV &lt;&lt; <span class="stringliteral">&quot;Received a data packet addressed to me,&quot;</span>
           &lt;&lt; <span class="stringliteral">&quot; preparing an ack...&quot;</span> &lt;&lt; endl;

<span class="comment">//        nbRxFrames++;</span>

        <span class="keywordflow">if</span>(ackMessage != NULL)
          <span class="keyword">delete</span> ackMessage;
        ackMessage = <span class="keyword">new</span> MacPkt(<span class="stringliteral">&quot;CSMA-Ack&quot;</span>);
        ackMessage-&gt;setSrcAddr(<a class="code" href="a00026.html#a8a26df9da07801d8ccb530530ef57ee2" title="MAC address.">myMacAddr</a>);
        ackMessage-&gt;setDestAddr(src);
        ackMessage-&gt;setBitLength(<a class="code" href="a00067.html#a3fba7040140a46c800ea94560fe0113a" title="The bit length of the ACK packet.">ackLength</a>);
        <span class="comment">//Check for duplicates by checking expected seqNr of sender</span>
        <span class="keywordflow">if</span>(SeqNrChild.find(src) == SeqNrChild.end()) {
          <span class="comment">//no record of current child -&gt; add expected next number to map</span>
          SeqNrChild[src] = SeqNr + 1;
          debugEV &lt;&lt; <span class="stringliteral">&quot;Adding a new child to the map of Sequence numbers:&quot;</span> &lt;&lt; src &lt;&lt; endl;
          <a class="code" href="a00067.html#a23b4dba9c913ac458f38091b2a7de71d">executeMac</a>(EV_FRAME_RECEIVED, macPkt);
        }
        <span class="keywordflow">else</span> {
          ExpectedNr = SeqNrChild[src];
          debugEV &lt;&lt; <span class="stringliteral">&quot;Expected Sequence number is &quot;</span> &lt;&lt; ExpectedNr &lt;&lt;
          <span class="stringliteral">&quot; and number of packet is &quot;</span> &lt;&lt; SeqNr &lt;&lt; endl;
          <span class="keywordflow">if</span>(SeqNr &lt; ExpectedNr) {
            <span class="comment">//Duplicate Packet, count and do not send to upper layer</span>
            nbDuplicates++;
            <a class="code" href="a00067.html#a23b4dba9c913ac458f38091b2a7de71d">executeMac</a>(EV_DUPLICATE_RECEIVED, macPkt);
          }
          <span class="keywordflow">else</span> {
            SeqNrChild[src] = SeqNr + 1;
            <a class="code" href="a00067.html#a23b4dba9c913ac458f38091b2a7de71d">executeMac</a>(EV_FRAME_RECEIVED, macPkt);
          }
        }

      } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(<a class="code" href="a00067.html#ac75e73d1a95881bcdcb125f13876e996" title="A queue to store packets from upper layer in case another packet is still waiting for transmission...">macQueue</a>.size() != 0) {

        <span class="comment">// message is an ack, and it is for us.</span>
        <span class="comment">// Is it from the right node ?</span>
          macpkt_ptr_t firstPacket = <span class="keyword">static_cast&lt;</span>macpkt_ptr_t<span class="keyword">&gt;</span>(<a class="code" href="a00067.html#ac75e73d1a95881bcdcb125f13876e996" title="A queue to store packets from upper layer in case another packet is still waiting for transmission...">macQueue</a>.front());
        <span class="keywordflow">if</span>(src == firstPacket-&gt;getDestAddr()) {
          nbRecvdAcks++;
          <a class="code" href="a00067.html#a23b4dba9c913ac458f38091b2a7de71d">executeMac</a>(EV_ACK_RECEIVED, macPkt);
        } <span class="keywordflow">else</span> {
          EV &lt;&lt; <span class="stringliteral">&quot;Error! Received an ack from an unexpected source: src=&quot;</span> &lt;&lt; src &lt;&lt; <span class="stringliteral">&quot;, I was expecting from node addr=&quot;</span> &lt;&lt; firstPacket-&gt;getDestAddr() &lt;&lt; endl;
          <span class="keyword">delete</span> macPkt;
        }
      } <span class="keywordflow">else</span> {
        EV &lt;&lt; <span class="stringliteral">&quot;Error! Received an Ack while my send queue was empty. src=&quot;</span> &lt;&lt; src &lt;&lt; <span class="stringliteral">&quot;.&quot;</span> &lt;&lt; endl;
        <span class="keyword">delete</span> macPkt;
      }
    }
  }
  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="a00117.html#a3890f1c7314c5695e32252468e6bd5a5" title="Test if a L2 address (pSrcAddr) is a broadcast address.">LAddress::isL2Broadcast</a>(dest)) {
    <a class="code" href="a00067.html#a23b4dba9c913ac458f38091b2a7de71d">executeMac</a>(EV_BROADCAST_RECEIVED, macPkt);
  } <span class="keywordflow">else</span> {
    debugEV &lt;&lt; <span class="stringliteral">&quot;packet not for me, deleting...\n&quot;</span>;
    <span class="keyword">delete</span> macPkt;
  }
}
</pre></div>
</div>
</div>
<a class="anchor" id="ad85c18d90e41eb2074593a44b64ab855"></a><!-- doxytag: member="csma::handleUpperMsg" ref="ad85c18d90e41eb2074593a44b64ab855" args="(cMessage *)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void csma::handleUpperMsg </td>
          <td>(</td>
          <td class="paramtype">cMessage *&#160;</td>
          <td class="paramname"><em>msg</em></td><td>)</td>
          <td><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Handle messages from upper layer. </p>
<p>Encapsulates the message to be transmitted and pass it on to the FSM main method for further processing. </p>

<p>Reimplemented from <a class="el" href="a00026.html#a6de2ca07018de313a7147a03e6d77bff">BaseMacLayer</a>.</p>

<p>References <a class="el" href="a00067.html#a23b4dba9c913ac458f38091b2a7de71d">executeMac()</a>, <a class="el" href="a00026.html#a48135ffa21044a71d92149d5301f9deb">BaseMacLayer::getUpperDestinationFromControlInfo()</a>, <a class="el" href="a00026.html#a26ddb186455b73c8dc8b5698296804d2">BaseMacLayer::headerLength</a>, <a class="el" href="a00026.html#a8a26df9da07801d8ccb530530ef57ee2">BaseMacLayer::myMacAddr</a>, and <a class="el" href="a00067.html#a51f34d63f063978e4077e290ed96579d">useMACAcks</a>.</p>
<div class="fragment"><pre class="fragment">                                       {
  <span class="comment">//macpkt_ptr_tmacPkt = encapsMsg(msg);</span>
  macpkt_ptr_t macPkt = <span class="keyword">new</span> MacPkt(msg-&gt;getName());
  macPkt-&gt;setBitLength(<a class="code" href="a00026.html#a26ddb186455b73c8dc8b5698296804d2" title="Pointer to the arp module.">headerLength</a>);
  cObject *<span class="keyword">const</span> cInfo = msg-&gt;removeControlInfo();
  debugEV&lt;&lt;<span class="stringliteral">&quot;CSMA received a message from upper layer, name is &quot;</span> &lt;&lt; msg-&gt;getName() &lt;&lt;<span class="stringliteral">&quot;, CInfo removed, mac addr=&quot;</span>&lt;&lt; <a class="code" href="a00026.html#a48135ffa21044a71d92149d5301f9deb" title="Extracts the MAC address from the &quot;control info&quot; structure (object).">getUpperDestinationFromControlInfo</a>(cInfo) &lt;&lt; endl;
  <a class="code" href="a00117.html#aea56b60dcb5ae8c2bde465271daf7210" title="Type definition for a L2 (MAC) address.">LAddress::L2Type</a> dest = <a class="code" href="a00026.html#a48135ffa21044a71d92149d5301f9deb" title="Extracts the MAC address from the &quot;control info&quot; structure (object).">getUpperDestinationFromControlInfo</a>(cInfo);
  macPkt-&gt;setDestAddr(dest);
  <span class="keyword">delete</span> cInfo;
  macPkt-&gt;setSrcAddr(<a class="code" href="a00026.html#a8a26df9da07801d8ccb530530ef57ee2" title="MAC address.">myMacAddr</a>);

  <span class="keywordflow">if</span>(<a class="code" href="a00067.html#a51f34d63f063978e4077e290ed96579d" title="Stores if the MAC expects Acks for Unicast packets.">useMACAcks</a>) {
    <span class="keywordflow">if</span>(SeqNrParent.find(dest) == SeqNrParent.end()) {
      <span class="comment">//no record of current parent -&gt; add next sequence number to map</span>
      SeqNrParent[dest] = 1;
      macPkt-&gt;setSequenceId(0);
      debugEV &lt;&lt; <span class="stringliteral">&quot;Adding a new parent to the map of Sequence numbers:&quot;</span> &lt;&lt; dest &lt;&lt; endl;
    }
    <span class="keywordflow">else</span> {
      macPkt-&gt;setSequenceId(SeqNrParent[dest]);
      debugEV &lt;&lt; <span class="stringliteral">&quot;Packet send with sequence number = &quot;</span> &lt;&lt; SeqNrParent[dest] &lt;&lt; endl;
      SeqNrParent[dest]++;
    }
  }

  <span class="comment">//RadioAccNoise3PhyControlInfo *pco = new RadioAccNoise3PhyControlInfo(bitrate);</span>
  <span class="comment">//macPkt-&gt;setControlInfo(pco);</span>
  assert(static_cast&lt;cPacket*&gt;(msg));
  macPkt-&gt;encapsulate(static_cast&lt;cPacket*&gt;(msg));
  debugEV &lt;&lt;<span class="stringliteral">&quot;pkt encapsulated, length: &quot;</span> &lt;&lt; macPkt-&gt;getBitLength() &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;
  <a class="code" href="a00067.html#a23b4dba9c913ac458f38091b2a7de71d">executeMac</a>(EV_SEND_REQUEST, macPkt);
}
</pre></div>
</div>
</div>
<a class="anchor" id="a24e7a48bd1d9036139c75b558ade4161"></a><!-- doxytag: member="csma::initialize" ref="a24e7a48bd1d9036139c75b558ade4161" args="(int)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void csma::initialize </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>stage</em></td><td>)</td>
          <td><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Initialization of the module and some variables. </p>
<p>Initialize the of the omnetpp.ini variables in stage 1. In stage two subscribe to the RadioState. </p>

<p>Reimplemented from <a class="el" href="a00026.html#a61c82dc3b225eac37f7fa9936c28c2c3">BaseMacLayer</a>.</p>

<p>Reimplemented in <a class="el" href="a00068.html#abbb7175c6f28345ca29c3ca6f98732fc">CSMA802154</a>.</p>

<p>References <a class="el" href="a00067.html#a3fba7040140a46c800ea94560fe0113a">ackLength</a>, <a class="el" href="a00067.html#ac820e37e2f86d7131a66aa6d1636cd69">aTurnaroundTime</a>, <a class="el" href="a00067.html#a63f8c5595546dedb2d2f779b2f88fc7b">aUnitBackoffPeriod</a>, <a class="el" href="a00067.html#af9dc9268929f470a2b1dc196f4dd1ad0">backoffMethod</a>, <a class="el" href="a00067.html#af881ff622dc82a06fc14008d67a0d084">bitrate</a>, <a class="el" href="a00025.html#ad8ba02d92dd106da1d85192eb28250c0">BaseLayer::catDroppedPacketSignal</a>, <a class="el" href="a00067.html#ae54073ef32d73822112cbc3ccfd5cd20">ccaDetectionTime</a>, <a class="el" href="a00067.html#ad6c37215e83748e9270a9772727f021da7ff1f1cf6a8bc1239290f360074513c5">CONSTANT</a>, <a class="el" href="a00067.html#ab8c7954aa7b5dc31268b3673a358e9f9">droppedPacket</a>, <a class="el" href="a00067.html#ad6c37215e83748e9270a9772727f021dab16652c86ace580cf5279d6c1538f549">EXPONENTIAL</a>, <a class="el" href="a00026.html#a68f36d36168a8ba5c8a4c84c17f1ba40">BaseMacLayer::getConnectionManager()</a>, <a class="el" href="a00026.html#ae51d8e3e0977cfc1d4f10f8135378fc4">BaseMacLayer::getNic()</a>, <a class="el" href="a00067.html#aa2d96f20753eff74aa1b9b3251523d24">initialCW</a>, <a class="el" href="a00201.html#aa01f017b96087bc252445206777e0080">simsignalwrap_t::initialize()</a>, <a class="el" href="a00067.html#ad6c37215e83748e9270a9772727f021da990e04ecf52a42619a49d0161f4f3421">LINEAR</a>, <a class="el" href="a00067.html#ac9f2b5914cfbdd9763531913f0756eb7">macAckWaitDuration</a>, <a class="el" href="a00067.html#a07d8675d0999963f22caa47b90feee7b">macMaxBE</a>, <a class="el" href="a00067.html#a8651bf006f28d69523c43d2aea774f7c">macMaxCSMABackoffs</a>, <a class="el" href="a00067.html#af7b3c7c2d0028579026dd17a267d4a72">macMaxFrameRetries</a>, <a class="el" href="a00067.html#aec2a85f71170231d175a7e5f453488bf">macMinBE</a>, <a class="el" href="a00067.html#a412a3b42a3212ab8a5dd1fcca2976d75">macState</a>, <a class="el" href="a00067.html#aa01f7215a8fccd726da22a0721994580">NB</a>, <a class="el" href="a00067.html#a384d9dce68d3db1b258369095e5b12a4">nicId</a>, <a class="el" href="a00067.html#a6c5dda6e483befcd9166dd2d1c099ff1">queueLength</a>, <a class="el" href="a00067.html#a2de1e148306253a3b7a33ae2c47201dc">rxSetupTime</a>, <a class="el" href="a00088.html#aef3c55476a292fea6434cc1c4c27f822">DroppedPacket::setReason()</a>, <a class="el" href="a00067.html#a4c4485a6c261026fbb39eee038c61d35">sifs</a>, <a class="el" href="a00067.html#a1b4834898677ae70f70e336a5af6bea4">stats</a>, <a class="el" href="a00067.html#af0459af5600cded297d8baaebf93270a">trace</a>, <a class="el" href="a00067.html#a6249492db8b5f2240aefd33ba1bbf04e">txAttempts</a>, <a class="el" href="a00067.html#a45229ade2d3472af4c427384443fbd9f">txPower</a>, and <a class="el" href="a00067.html#a51f34d63f063978e4077e290ed96579d">useMACAcks</a>.</p>
<div class="fragment"><pre class="fragment">                               {
  <a class="code" href="a00067.html#a24e7a48bd1d9036139c75b558ade4161" title="Initialization of the module and some variables.">BaseMacLayer::initialize</a>(stage);

  <span class="keywordflow">if</span> (stage == 0) {
    <a class="code" href="a00025.html#ad8ba02d92dd106da1d85192eb28250c0" title="Signal for dropped packets.">BaseLayer::catDroppedPacketSignal</a>.<a class="code" href="a00201.html#aa01f017b96087bc252445206777e0080">initialize</a>();

    <a class="code" href="a00067.html#a51f34d63f063978e4077e290ed96579d" title="Stores if the MAC expects Acks for Unicast packets.">useMACAcks</a> = par(<span class="stringliteral">&quot;useMACAcks&quot;</span>).boolValue();
    <a class="code" href="a00067.html#a6c5dda6e483befcd9166dd2d1c099ff1" title="length of the queue">queueLength</a> = par(<span class="stringliteral">&quot;queueLength&quot;</span>);
    <a class="code" href="a00067.html#a4c4485a6c261026fbb39eee038c61d35" title="Maximum time between a packet and its ACK.">sifs</a> = par(<span class="stringliteral">&quot;sifs&quot;</span>);
    transmissionAttemptInterruptedByRx = <span class="keyword">false</span>;
    nbTxFrames = 0;
    nbRxFrames = 0;
    nbMissedAcks = 0;
    nbTxAcks = 0;
    nbRecvdAcks = 0;
    nbDroppedFrames = 0;
    nbDuplicates = 0;
    nbBackoffs = 0;
    backoffValues = 0;
    <a class="code" href="a00067.html#a1b4834898677ae70f70e336a5af6bea4" title="Records general statistics?">stats</a> = par(<span class="stringliteral">&quot;stats&quot;</span>);
    <a class="code" href="a00067.html#af0459af5600cded297d8baaebf93270a" title="Record out put vectors?">trace</a> = par(<span class="stringliteral">&quot;trace&quot;</span>);
    <a class="code" href="a00067.html#a8651bf006f28d69523c43d2aea774f7c" title="maximum number of backoffs before frame drop">macMaxCSMABackoffs</a> = par(<span class="stringliteral">&quot;macMaxCSMABackoffs&quot;</span>);
    <a class="code" href="a00067.html#af7b3c7c2d0028579026dd17a267d4a72" title="maximum number of frame retransmissions without ack">macMaxFrameRetries</a> = par(<span class="stringliteral">&quot;macMaxFrameRetries&quot;</span>);
    <a class="code" href="a00067.html#ac9f2b5914cfbdd9763531913f0756eb7" title="The amount of time the MAC waits for the ACK of a packet.">macAckWaitDuration</a> = par(<span class="stringliteral">&quot;macAckWaitDuration&quot;</span>).doubleValue();
    <a class="code" href="a00067.html#a63f8c5595546dedb2d2f779b2f88fc7b" title="base time unit for calculating backoff durations">aUnitBackoffPeriod</a> = par(<span class="stringliteral">&quot;aUnitBackoffPeriod&quot;</span>).doubleValue();
    <a class="code" href="a00067.html#ae54073ef32d73822112cbc3ccfd5cd20" title="CCA detection time.">ccaDetectionTime</a> = par(<span class="stringliteral">&quot;ccaDetectionTime&quot;</span>).doubleValue();
    <a class="code" href="a00067.html#a2de1e148306253a3b7a33ae2c47201dc" title="Time to setup radio from sleep to Rx state.">rxSetupTime</a> = par(<span class="stringliteral">&quot;rxSetupTime&quot;</span>).doubleValue();
    <a class="code" href="a00067.html#ac820e37e2f86d7131a66aa6d1636cd69" title="Time to switch radio from Rx to Tx state.">aTurnaroundTime</a> = par(<span class="stringliteral">&quot;aTurnaroundTime&quot;</span>).doubleValue();
    <a class="code" href="a00067.html#af881ff622dc82a06fc14008d67a0d084" title="the bit rate at which we transmit">bitrate</a> = par(<span class="stringliteral">&quot;bitrate&quot;</span>);
    <a class="code" href="a00067.html#a3fba7040140a46c800ea94560fe0113a" title="The bit length of the ACK packet.">ackLength</a> = par(<span class="stringliteral">&quot;ackLength&quot;</span>);
    ackMessage = NULL;

    <span class="comment">//init parameters for backoff method</span>
    std::string backoffMethodStr = par(<span class="stringliteral">&quot;backoffMethod&quot;</span>).stdstringValue();
    <span class="keywordflow">if</span>(backoffMethodStr == <span class="stringliteral">&quot;exponential&quot;</span>) {
      <a class="code" href="a00067.html#af9dc9268929f470a2b1dc196f4dd1ad0" title="Defines the backoff method to be used.">backoffMethod</a> = <a class="code" href="a00067.html#ad6c37215e83748e9270a9772727f021dab16652c86ace580cf5279d6c1538f549" title="Exponentially increasing back-off time.">EXPONENTIAL</a>;
      <a class="code" href="a00067.html#aec2a85f71170231d175a7e5f453488bf" title="Minimum backoff exponent. Only used for exponential backoff method.">macMinBE</a> = par(<span class="stringliteral">&quot;macMinBE&quot;</span>);
      <a class="code" href="a00067.html#a07d8675d0999963f22caa47b90feee7b" title="Maximum backoff exponent. Only used for exponential backoff method.">macMaxBE</a> = par(<span class="stringliteral">&quot;macMaxBE&quot;</span>);
    }
    <span class="keywordflow">else</span> {
      <span class="keywordflow">if</span>(backoffMethodStr == <span class="stringliteral">&quot;linear&quot;</span>) {
        <a class="code" href="a00067.html#af9dc9268929f470a2b1dc196f4dd1ad0" title="Defines the backoff method to be used.">backoffMethod</a> = <a class="code" href="a00067.html#ad6c37215e83748e9270a9772727f021da990e04ecf52a42619a49d0161f4f3421" title="Linear increasing back-off time.">LINEAR</a>;
      }
      <span class="keywordflow">else</span> <span class="keywordflow">if</span> (backoffMethodStr == <span class="stringliteral">&quot;constant&quot;</span>) {
        <a class="code" href="a00067.html#af9dc9268929f470a2b1dc196f4dd1ad0" title="Defines the backoff method to be used.">backoffMethod</a> = <a class="code" href="a00067.html#ad6c37215e83748e9270a9772727f021da7ff1f1cf6a8bc1239290f360074513c5" title="Constant back-off time.">CONSTANT</a>;
      }
      <span class="keywordflow">else</span> {
        error(<span class="stringliteral">&quot;Unknown backoff method \&quot;%s\&quot;.\</span>
<span class="stringliteral">             Use \&quot;constant\&quot;, \&quot;linear\&quot; or \&quot;\</span>
<span class="stringliteral">             \&quot;exponential\&quot;.&quot;</span>, backoffMethodStr.c_str());
      }
      <a class="code" href="a00067.html#aa2d96f20753eff74aa1b9b3251523d24" title="initial contention window size Only used for linear and constant backoff method.">initialCW</a> = par(<span class="stringliteral">&quot;contentionWindow&quot;</span>);
    }
    <a class="code" href="a00067.html#aa01f7215a8fccd726da22a0721994580" title="number of backoff performed until now for current frame">NB</a> = 0;

    <a class="code" href="a00067.html#a45229ade2d3472af4c427384443fbd9f" title="The power (in mW) to transmit with.">txPower</a> = par(<span class="stringliteral">&quot;txPower&quot;</span>).doubleValue();

    <a class="code" href="a00067.html#ab8c7954aa7b5dc31268b3673a358e9f9" title="Inspect reasons for dropped packets.">droppedPacket</a>.<a class="code" href="a00088.html#aef3c55476a292fea6434cc1c4c27f822" title="set the state of the radio">setReason</a>(DroppedPacket::NONE);
    <a class="code" href="a00067.html#a384d9dce68d3db1b258369095e5b12a4" title="publish dropped packets nic wide">nicId</a> = <a class="code" href="a00026.html#ae51d8e3e0977cfc1d4f10f8135378fc4" title="Pointer to nic Module.">getNic</a>()-&gt;getId();

    <span class="comment">// initialize the timers</span>
    backoffTimer = <span class="keyword">new</span> cMessage(<span class="stringliteral">&quot;timer-backoff&quot;</span>);
    ccaTimer = <span class="keyword">new</span> cMessage(<span class="stringliteral">&quot;timer-cca&quot;</span>);
    sifsTimer = <span class="keyword">new</span> cMessage(<span class="stringliteral">&quot;timer-sifs&quot;</span>);
    rxAckTimer = <span class="keyword">new</span> cMessage(<span class="stringliteral">&quot;timer-rxAck&quot;</span>);
    <a class="code" href="a00067.html#a412a3b42a3212ab8a5dd1fcca2976d75" title="keep track of MAC state">macState</a> = IDLE_1;
    <a class="code" href="a00067.html#a6249492db8b5f2240aefd33ba1bbf04e" title="count the number of tx attempts">txAttempts</a> = 0;

    <span class="comment">//check parameters for consistency</span>
    cModule* phyModule = <a class="code" href="a00093.html" title="Provides method templates to find omnet modules.">FindModule&lt;BasePhyLayer*&gt;::findSubModule</a>(<a class="code" href="a00026.html#ae51d8e3e0977cfc1d4f10f8135378fc4" title="Pointer to nic Module.">getNic</a>());

    <span class="comment">//aTurnaroundTime should match (be equal or bigger) the RX to TX</span>
    <span class="comment">//switching time of the radio</span>
    <span class="keywordflow">if</span>(phyModule-&gt;hasPar(<span class="stringliteral">&quot;timeRXToTX&quot;</span>)) {
      simtime_t rxToTx = phyModule-&gt;par(<span class="stringliteral">&quot;timeRXToTX&quot;</span>).doubleValue();
      <span class="keywordflow">if</span>( rxToTx &gt; <a class="code" href="a00067.html#ac820e37e2f86d7131a66aa6d1636cd69" title="Time to switch radio from Rx to Tx state.">aTurnaroundTime</a>)
      {
        opp_warning(<span class="stringliteral">&quot;Parameter \&quot;aTurnaroundTime\&quot; (%f) does not match&quot;</span>
              <span class="stringliteral">&quot; the radios RX to TX switching time (%f)! It&quot;</span>
              <span class="stringliteral">&quot; should be equal or bigger&quot;</span>,
              SIMTIME_DBL(<a class="code" href="a00067.html#ac820e37e2f86d7131a66aa6d1636cd69" title="Time to switch radio from Rx to Tx state.">aTurnaroundTime</a>), SIMTIME_DBL(rxToTx));
      }
    }

  } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(stage == 1) {
    <a class="code" href="a00019.html" title="Module to control the channel and handle all connection related stuff.">BaseConnectionManager</a>* cc = <a class="code" href="a00026.html#a68f36d36168a8ba5c8a4c84c17f1ba40" title="Returns a pointer to this MACs NICs ConnectionManager module.">getConnectionManager</a>();

      <span class="keywordflow">if</span>(cc-&gt;hasPar(<span class="stringliteral">&quot;pMax&quot;</span>) &amp;&amp; <a class="code" href="a00067.html#a45229ade2d3472af4c427384443fbd9f" title="The power (in mW) to transmit with.">txPower</a> &gt; cc-&gt;par(<span class="stringliteral">&quot;pMax&quot;</span>).doubleValue())
            opp_error(<span class="stringliteral">&quot;TranmitterPower can&#39;t be bigger than pMax in ConnectionManager! &quot;</span>
                  <span class="stringliteral">&quot;Please adjust your omnetpp.ini file accordingly&quot;</span>);

      debugEV &lt;&lt; <span class="stringliteral">&quot;queueLength = &quot;</span> &lt;&lt; <a class="code" href="a00067.html#a6c5dda6e483befcd9166dd2d1c099ff1" title="length of the queue">queueLength</a>
    &lt;&lt; <span class="stringliteral">&quot; bitrate = &quot;</span> &lt;&lt; <a class="code" href="a00067.html#af881ff622dc82a06fc14008d67a0d084" title="the bit rate at which we transmit">bitrate</a>
    &lt;&lt; <span class="stringliteral">&quot; backoff method = &quot;</span> &lt;&lt; par(<span class="stringliteral">&quot;backoffMethod&quot;</span>).stringValue() &lt;&lt; endl;

    debugEV &lt;&lt; <span class="stringliteral">&quot;finished csma init stage 1.&quot;</span> &lt;&lt; endl;
  }
}
</pre></div>
</div>
</div>
<hr/><h2>Member Data Documentation</h2>
<a class="anchor" id="a4c4485a6c261026fbb39eee038c61d35"></a><!-- doxytag: member="csma::sifs" ref="a4c4485a6c261026fbb39eee038c61d35" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">simtime_t <a class="el" href="a00067.html#a4c4485a6c261026fbb39eee038c61d35">csma::sifs</a><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Maximum time between a packet and its ACK. </p>
<p>Usually this is slightly more then the tx-rx turnaround time The channel should stay clear within this period of time. </p>

<p>Referenced by <a class="el" href="a00067.html#a24e7a48bd1d9036139c75b558ade4161">initialize()</a>.</p>

</div>
</div>
<a class="anchor" id="a6249492db8b5f2240aefd33ba1bbf04e"></a><!-- doxytag: member="csma::txAttempts" ref="a6249492db8b5f2240aefd33ba1bbf04e" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned int <a class="el" href="a00067.html#a6249492db8b5f2240aefd33ba1bbf04e">csma::txAttempts</a><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>count the number of tx attempts </p>
<p>This holds the number of transmission attempts for the current frame. </p>

<p>Referenced by <a class="el" href="a00067.html#a24e7a48bd1d9036139c75b558ade4161">initialize()</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>D:/Projects/MiXiM/extsrc/mixim/src/modules/mac/<a class="el" href="a00426_source.html">csma.h</a></li>
<li>D:/Projects/MiXiM/extsrc/mixim/src/modules/mac/csma.cc</li>
</ul>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="a00067.html">csma</a>      </li>

    <li class="footer">Generated on Tue Mar 5 2013 21:26:31 for MiXiM by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
